package com.lc.tgxm.activity;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;

import com.lc.tgxm.R;
import com.lc.tgxm.widget.ViewTitle;


/**
 * MyWebviewActivity
 * Created by Lei on 2018/5/10.
 */
public class MyWebviewActivity extends BaseActivity {
    private WebView wv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initContenViewAndBack(R.layout.activity_mywebview, R.string.app_name);
        View ivLeft = viewTitle.activateView(ViewTitle.TitleType.BACK);
        ivLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onBackPressed();
            }
        });

        wv = findViewById(R.id.wv_main);

        String title = getIntent().getStringExtra("title");
        String url = getIntent().getStringExtra("url");

        if (title != null) {
            setTitleName(title);
        }

        if (url != null) {
            initWebView(wv, url);
        }
    }

    @Override
    public void onBackPressed() {
        if (wv.canGoBack()) {
            wv.goBack();
        } else {
            super.onBackPressed();
        }
    }

}